FROM bishengjdk-17:latest

COPY gosu-arm64 /usr/local/bin/gosu

ENV GOSU_VERSION 1.17
RUN set -eux; \
    chmod +x /usr/local/bin/gosu

RUN set -eux; \
    dnf install -y unzip && \
    groupadd -g 70 rocketmq; \
    useradd -r -u 70 -g rocketmq -m -d /home/rocketmq rocketmq && \
    dnf clean all

ARG VERSION=5.3.3

RUN set -eux; \
    curl -O https://mirrors.tuna.tsinghua.edu.cn/apache/rocketmq/${VERSION}/rocketmq-all-${VERSION}-bin-release.zip && \
    unzip rocketmq-all-${VERSION}-bin-release.zip -d /opt && \
    mv /opt/rocketmq-all-${VERSION}-bin-release /opt/rocketmq && \
    rm -rf rocketmq-all-${VERSION}-bin-release.zip && \
    chown -R rocketmq:rocketmq /opt/rocketmq

ENV ROCKETMQ_HOME /opt/rocketmq
ENV PATH $PATH:$ROCKETMQ_HOME/bin

EXPOSE 9876 10909 10911 10912 8080 8081
VOLUME ["/home/rocketmq/store", "/home/rocketmq/logs", "/home/rocketmq/conf"]

COPY entrypoint.sh /usr/local/bin/
RUN chmod 755 /usr/local/bin/entrypoint.sh; \
    ln -s /usr/local/bin/entrypoint.sh / # backwards compat

ENTRYPOINT ["entrypoint.sh"]
CMD ["echo", "run 'sh mqnamesrv', 'sh mqbroker', 'sh mqproxy' to use rocketmq."]
